<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text" placeholder="请输入用户名" name="" id="">
    <input type="text" placeholder="请输入密码" name="" id="">
    <input type="text" placeholder="请输入 昵称" name="" id="">
    <button>注册</button>
    <script>
        let btn = document.querySelector("button")
        let inp = document.querySelectorAll("input")
        btn.onclick = function () {
            let xhr = new XMLHttpRequest()
            xhr.open('post', 'http://wish.byesame.com/register')
            xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
            xhr.send(`userName=${inp[0].value}&passWord=${inp[1].value}&name=${inp[2].value}&role=3`)
            xhr.onreadystatechange = function () {
                if (xhr.readyState == 4) {
                    console.log(JSON.parse(xhr.responseText));
                }
            }
        }

    </script>
</body>

</html>